package org.example.data_stream;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;
import java.util.List;

/**
 * @author shenguangyang
 */
public class E05_TransformFilter {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        List<Event> events = new ArrayList<Event>() {{
            add(new Event("user02", "./cart", 1660095536L));
            add(new Event("user01", "./home", 1660095536L));
            add(new Event("user01", "./home1", 1660095536L));
        }};
        DataStream<Event> streamSource = env.fromCollection(events);

        DataStream<Event> stream1 = streamSource.filter(event -> event.getUser().equals("user01"));

        stream1.print();

        env.execute();
    }
}
